<!-- 出维修确认页面 -->
<template>
  <div>
    <basic-container>
      <avue-crud
        :option="option"
        :table-loading="loading"
        :search.sync="search"
        :data="data"
        :page.sync="page"
        ref="crud"
        @search-change="searchChange"
        @search-reset="searchReset"
        @selection-change="selectionChange"
        @current-change="currentChange"
        @size-change="sizeChange"
        @refresh-change="refreshChange"
        @on-load="onLoad"
      >
        <template #menu="{ row }">
          <el-button v-if="permission.repairout_outRepair" type="text" size="small" @click="handleRepair(row)">处理</el-button>
        </template>
        <!--                <template slot="menuRight">-->
        <!--                  <user-table-config :option="option" @confirm="(val) => handleSetUserConfig(val, pageCode)"></user-table-config>-->
        <!--                </template>-->
      </avue-crud>
    </basic-container>
    <el-dialog title="处理" :visible.sync="dialogVisible" :modal-append-to-body="false" top="3vh" :fullscreen="true">
      <avue-form ref="repairForm" v-model="repairForm" :option="repairOption">
        <template slot="info">
          <div v-if="repairForm.repairOutResult && repairForm.repairOutResult === 'REPAIR_OUT'">
            <div v-for="(item, index) in refuelingList" :key="index">
              <div>
                <span>{{ !index ? '原材料换料' : '子件换料' }}</span>
              </div>
              <avue-crud
                ref="infoCrud"
                :option="item"
                :data="!index ? repairForm.materialRefuelingVOList || [] : repairForm.componentRefuelingVOList || []"
                v-model="repairForm"
              >
              </avue-crud>
            </div>
          </div>
          <div v-else></div>
        </template>
        <template slot="imageList">
          <div class="img-list">
            <template v-for="(item, index) in repairForm.attachmentVOList">
              <div v-if="item" style="margin: 5px 10px; display: flex; flex-direction: column" :key="index">
                <img style="width: 100px; height: 100px" :src="item.link ? item.link : ''" @click="openPreview('0', item.link)" />
                <button type="button" :class="`el-button el-button--text el-button--small downLoadFile${index}`" @click="handleDownload(item.link)">
                  <i class="el-icon-download"></i><span>下载</span>
                </button>
              </div>
            </template>
          </div>
        </template>
        <template slot="repairWay">
          <div class="repairWay">
            <div style="display: flex; padding: 10px">
              <el-radio style="margin-top: 9px" v-model="repairForm.repairOutResult" label="REPAIR_OUT" v-remove-aria-hidden>维修合格，出维修</el-radio>
              <span class="station" v-if="repairForm.repairOutResult == 'REPAIR_OUT'">
                <label style="width: 150px"><span style="color: red">*</span>指定返回工站：</label>
                <el-select v-model="repairForm.returnRouteId" placeholder="请选择">
                  <el-option v-for="item in stationList" :key="item.value" :label="item.label" :value="item.value"></el-option>
                </el-select>
              </span>
            </div>
            <el-radio style="padding: 10px" v-model="repairForm.repairOutResult" label="REPAIR_REPEAT" v-remove-aria-hidden>维修不合格，返回重修</el-radio>
            <el-radio style="padding: 10px" v-model="repairForm.repairOutResult" label="REPAIR_SCRAP" v-remove-aria-hidden>无法维修，报废</el-radio>
          </div>
        </template>
      </avue-form>
      <span slot="footer">
        <el-button size="small" icon="el-icon-delete" @click="dialogVisible = false">取 消</el-button>
        <el-button size="small" type="primary" icon="el-icon-check" v-preventReClick @click="repairSubmit">提 交</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import repairDetail from '@/components/repair/detail.vue';
import { getPageList, getDetail, getRouter, saveRePair } from '@/api/repair/repairoutRefactor.js';
import website from '@/config/website';
import { getToken } from '@/util/auth';
import { mapGetters } from 'vuex';

export default {
  name: 'RepairRepairOut',
  components: {
    repairDetail
  },
  data() {
    return {
      search: {},
      query: {},
      loading: true,
      dataTempList: [], //临时缓存数据
      page: {
        pageSize: 20,
        currentPage: 1,
        total: 0
      },
      selectionList: [],
      stationList: [],
      refuelingList: [
        {
          height: 200,
          calcHeight: 30,
          tip: false,
          searchShow: true,
          searchMenuSpan: 3,
          border: true,
          index: false,
          selection: true,
          dialogClickModal: false,
          labelWidth: 120,
          addBtn: false,
          editBtn: false,
          delBtn: false,
          viewBtn: false,
          columnBtn: false,
          menu: false,
          refreshBtn: false,
          column: [
            {
              label: '维修位号',
              prop: 'LocationCode'
            },
            {
              label: '录入类型',
              prop: 'inputType',
              type: 'select',
              dicData: [
                {
                  label: '无条码',
                  value: 'NONE_PACKING_SN'
                },
                {
                  label: '有条码',
                  value: 'HAVE_PACKING_SN'
                }
              ]
            },
            {
              label: '物料包装条码',
              prop: 'newSn'
            },
            {
              label: '物料编码',
              prop: 'newPartNo'
            },
            {
              label: '物料名称',
              prop: 'newPartName'
            },
            {
              label: '物料型号',
              prop: 'newPartModel'
            },
            {
              label: '物料品牌',
              prop: 'newPartBrand'
            },
            {
              label: '内部批次',
              prop: 'newLotNo'
            },
            {
              label: '维修用量',
              prop: 'quantity'
            }
          ]
        },
        {
          height: 200,
          calcHeight: 30,
          tip: false,
          searchShow: true,
          searchMenuSpan: 3,
          border: true,
          index: false,
          selection: true,
          dialogClickModal: false,
          labelWidth: 120,
          addBtn: false,
          editBtn: false,
          delBtn: false,
          viewBtn: false,
          columnBtn: false,
          menu: false,
          refreshBtn: false,
          column: [
            {
              label: '维修位号',
              prop: 'LocationCode'
            },
            {
              label: '旧子件序列号',
              prop: 'oldSn'
            },
            {
              label: '新子件序列号',
              prop: 'newSn'
            },
            {
              label: '产品编码',
              prop: 'newPartNo'
            },
            {
              label: '产品名称',
              prop: 'newPartName'
            },
            {
              label: '产品型号',
              prop: 'newPartModel'
            },
            {
              label: '维修用量',
              prop: 'quantity'
            }
          ]
        }
      ],
      repairForm: {
        repairOutResult: ''
      },
      repairOption: {
        submitBtn: false,
        emptyBtn: false,
        labelWidth: 120,
        span: 6,
        group: [
          {
            label: '基础信息',
            prop: 'baseInfo',
            icon: 'el-icon-vertical-bar',
            column: [
              {
                label: '序列号',
                prop: 'productSn',
                disabled: true
              },
              {
                label: '工单号',
                prop: 'workOrderNo',
                disabled: true
              },
              {
                label: '产品编码',
                prop: 'productPartNo',
                disabled: true
              },
              {
                label: '产品名称',
                prop: 'productPartName',
                disabled: true
              },
              {
                label: '产品型号',
                prop: 'productPartModel',
                disabled: true
              },
              {
                label: '工单计划数量',
                prop: 'planQuantity',
                disabled: true
              },
              {
                label: '工单完工数量',
                prop: 'completedQuantity',
                disabled: true
              },
              {
                label: '工单不良数',
                prop: 'ngQuantity',
                disabled: true
              }
            ]
          },
          {
            label: '不良信息',
            prop: 'failureInfo',
            icon: 'el-icon-vertical-bar',
            column: [
              {
                label: '不良现象',
                prop: 'badPhenomenonName',
                disabled: true
              },
              {
                label: '登记产线',
                prop: 'lineName',
                disabled: true
              },
              {
                label: '登记工序',
                prop: 'routeName',
                disabled: true
              },
              {
                label: '登记工位',
                prop: 'stationName',
                disabled: true
              },
              {
                label: '登记人员',
                prop: 'registerUserName',
                disabled: true
              },
              {
                label: '登记时间',
                prop: 'registerTime',
                disabled: true
              },
              {
                label: '判定人员',
                prop: 'confirmUserName',
                disabled: true
              },
              {
                label: '不良判定时间',
                prop: 'confirmTime',
                disabled: true
              },
              {
                label: '登记说明',
                prop: 'registerDescription',
                span: 12,
                disabled: true
              },
              {
                label: '判定说明',
                prop: 'confirmDescription',
                span: 12,
                disabled: true
              }
            ]
          },
          {
            label: '维修信息',
            prop: 'repairInfo',
            icon: 'el-icon-vertical-bar',
            column: [
              {
                label: '不良原因大类',
                prop: 'mainBadCauseName',
                disabled: true
              },
              {
                label: '不良原因小类',
                prop: 'subBadCauseName',
                disabled: true
              },
              {
                label: '原因说明',
                prop: 'badCauseDescription',
                span: 12,
                disabled: true
              },
              {
                label: '维修结果',
                prop: 'repairResult',
                disabled: true,
                type: 'select',
                dicData: [
                  { label: '维修完成', value: 'REPAIR_FINISHED' },
                  { label: '标记报废', value: 'MARK_SCRAP' }
                ]
              },
              {
                label: '维修说明',
                prop: 'repairDescription',
                span: 12,
                disabled: true
              },
              {
                label: '维修位号',
                prop: 'locationCode',
                disabled: true
              },
              {
                label: '维修人员',
                prop: 'repairUserName',
                disabled: true
              },
              {
                label: '维修时间',
                prop: 'repairTime',
                disabled: true
              },
              {
                label: '已维修次数',
                prop: 'repairTimes',
                disabled: true
              },
              {
                label: '',
                prop: 'info',
                labelWidth: 0,
                width: 0,
                span: 24,
                disabled: true
              },
              {
                label: '维修图片',
                prop: 'imageList',
                span: 24
              }
            ]
          },
          {
            label: '处理意见',
            prop: 'handleSuggest',
            icon: 'el-icon-vertical-bar',
            column: [
              {
                label: '',
                prop: 'repairWay',
                width: 0,
                labelWidth: 0,
                span: 24
              },
              {
                label: '出维修意见说明',
                prop: 'repairOutDescription',
                type: 'textarea',
                span: 24,
                maxRows: 3,
                minRows: 3,
                labelWidth: 160
              }
            ]
          }
        ]
      },
      option: {
        height: 'calc(100vh - 470px)',
        calcHeight: 30,
        tip: false,
        searchShow: true,
        searchMenuSpan: 24,
        searchMenuPosition: 'right',
        border: true,
        index: true,
        indexLabel: '序号',
        selection: true,
        dialogClickModal: false,
        labelWidth: 120,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        viewBtn: false,
        columnBtn: false,
        menu: true,
        menuWidth: 150,
        column: [
          {
            label: '工单号',
            prop: 'workOrderNo',
            search: true
          },
          {
            label: '产品序列号',
            prop: 'productSn',
            searchLabelWidth: 100,
            search: true
          },
          {
            label: '产品编码',
            prop: 'productPartNo',
            search: true
          },
          {
            label: '产品名称',
            prop: 'productPartName'
            // search: true
          },
          {
            label: '产品型号',
            prop: 'productPartModel',
            search: true
          },
          {
            label: '不良数',
            prop: 'badQuantity'
          },
          {
            label: '登记产线',
            prop: 'lineName',
            search: true
          },
          {
            label: '登记工序',
            prop: 'routeName',
            search: true
          },
          {
            label: '登记工位',
            prop: 'stationName',
            search: true
          },
          {
            label: '不良现象',
            prop: 'badPhenomenonName'
          },
          {
            label: '维修结果',
            prop: 'repairResult',
            type: 'select',
            search: true,
            dicData: [
              { label: '维修完成', value: 'REPAIR_FINISHED' },
              { label: '标记报废', value: 'MARK_SCRAP' }
            ]
          },
          // {
          //   label: '不良类型',
          //   prop: 'failureTypeName'
          // },
          // {
          //   label: '维修位号',
          //   prop: 'locationCode'
          // },
          {
            label: '维修人员',
            prop: 'repairUserName'
          },
          {
            label: '维修时间',
            prop: 'repairTime',
            searchType: 'datetimerange',
            searchLabelWidth: 100,
            searchSpan: 8,
            format: 'yyyy-MM-dd HH:mm:ss',
            valueFormat: 'yyyy-MM-dd HH:mm:ss',
            startPlaceholder: '开始时间',
            endPlaceholder: '结束时间',
            search: true
          },
          {
            label: '已维修次数',
            prop: 'repairTimes'
          }
        ]
      },
      data: [],
      dialogVisible: false,
      repairOutForm: {},
      repairOutOption: {
        submitBtn: false,
        emptyBtn: false,
        labelWidth: 115,
        column: [
          {
            label: '产品名称',
            prop: 'partName',
            disabled: true
          },
          {
            label: '产品序列号',
            prop: 'productSequenceNumber',
            disabled: true
          },
          {
            label: '不良现象',
            prop: 'failureName',
            type: 'textarea',
            maxRows: 3,
            minRows: 3,
            disabled: true
          },

          {
            label: '不良现象描述',
            prop: 'failureRemark',
            type: 'textarea',
            maxRows: 3,
            minRows: 3,
            disabled: true
          },
          {
            label: '不良原因大类',
            prop: 'mainCauseName',
            disabled: true
          },
          {
            label: '不良原因小类',
            prop: 'subCauseName',
            disabled: true
          },
          {
            label: '维修备注',
            prop: 'repairRemark',
            type: 'textarea',
            maxRows: 3,
            minRows: 3,
            disabled: true
          },
          {
            label: '维修图片查看',
            prop: 'imageList'
          },
          {
            label: '维修后去向',
            type: 'select',
            prop: 'qualifiedRouteId',
            dicData: [],
            span: 24,
            placeholder: '请选择 维修后去向',
            rules: [
              {
                required: true,
                message: '请选择维修后去向',
                trigger: 'blur'
              }
            ]
          }
        ]
      },
      scrapVisible: false,
      scrapForm: {},
      scrapOption: {
        submitBtn: false,
        emptyBtn: false,
        labelWidth: 115,
        column: [
          {
            label: '产品名称',
            prop: 'partName',
            disabled: true
          },
          {
            label: '产品序列号',
            prop: 'productSequenceNumber',
            disabled: true
          },
          {
            label: '不良现象',
            prop: 'failureName',
            type: 'textarea',
            maxRows: 3,
            minRows: 3,
            disabled: true
          },
          {
            label: '不良现象描述',
            prop: 'failureRemark',
            type: 'textarea',
            maxRows: 3,
            minRows: 3,
            disabled: true
          },
          {
            label: '不良原因大类',
            prop: 'mainCauseName',
            disabled: true
          },
          {
            label: '不良原因小类',
            prop: 'subCauseName',
            disabled: true
          },
          {
            label: '标记报废原因',
            prop: 'repairRemark',
            type: 'textarea',
            maxRows: 3,
            minRows: 3,
            disabled: true
          },
          {
            label: '报废图片查看',
            prop: 'imageList'
          },
          {
            label: '报废说明',
            prop: 'remark',
            type: 'textarea',
            maxRows: 3,
            minRows: 3,
            span: 24,
            rules: [
              {
                required: true,
                message: '请输入报废说明',
                trigger: 'blur'
              }
            ]
          }
        ]
      },
      outRepairType: '',
      repairStraightThroughRate: '', //维修直通率
      returnsWorkRate: '', //返回重修率
      scrapeRate: '' //报废率
    };
  },
  directives: {
    removeAriaHidden: {
      bind(event, bingding) {
        let ariaHidden = event.querySelectorAll('.el-radio__original');
        ariaHidden.forEach((item) => {
          item.removeAttribute('aria-hidden');
        });
      }
    }
  },
  computed: {
    ...mapGetters(['permission']),
    headersObj() {
      let header = { Authorization: `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}` };
      header['Blade-Auth'] = 'bearer ' + getToken();
      return header;
    },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids;
    },
    isDisableRepairBtn() {
      let flag = this.selectionList.every((item) => {
        return item.repairResult === '维修完成';
      });
      return this.selectionList.length > 0 ? flag : false;
    },
    isDisableScrapBtn() {
      let flag = this.selectionList.every((item) => {
        return item.repairResult === '标记报废';
      });
      return this.selectionList.length > 0 ? flag : false;
    }
  },
  watch: {},
  mounted() {
    this.$nextTick(() => {
      this.$structuralSplit();
    });
    // this.getCalculateRate();
  },
  methods: {
    // findNode(list = [], prop) {
    //   let node;
    //   list.forEach((ele) => {
    //     if (ele.prop === prop) node = ele;
    //   });
    //   return node;
    // },
    // radioInput(repairWay) {
    //   this.repairForm.qualifiedRouteId = '';
    //   let handleSuggest = this.findNode(this.repairOption.group, 'handleSuggest');
    //   let remark = this.findObject(handleSuggest.column, 'remark');
    //   if (this.repairForm.repairWay == 1) {
    //     remark.rules[0].required = false;
    //   } else {
    //     remark.rules[0].required = true;
    //   }
    //   if (this.repairForm.repairOutResult == 1 && this.repairForm.repairResult === '标记报废') {
    //     this.$message({
    //       type: 'warning',
    //       message: '维修结果为标记报废，无法出维修！'
    //     });
    //     this.repairForm.repairWay = '';
    //     return;
    //   }
    //   if (this.repairForm.repairOutResult == 3 && this.repairForm.repairResult === '维修完成') {
    //     this.$message({
    //       type: 'warning',
    //       message: '维修结果为维修完成，无法标记报废！'
    //     });
    //     this.repairForm.repairOutResult = '';
    //     return;
    //   }
    // },
    async repairSubmit() {
      if (!this.repairForm.repairOutResult) {
        this.$message({
          type: 'warning',
          message: '请选择处理意见'
        });
        return;
      }
      if (!this.repairForm.returnRouteId && this.repairForm.repairOutResult === 'REPAIR_OUT') {
        this.$message({
          type: 'warning',
          message: '请选择指定返回工站！'
        });
        return;
      }
      const data = {
        repairExecuteId: this.repairForm.id,
        repairOutResult: this.repairForm.repairOutResult,
        returnRouteId: this.repairForm.returnRouteId || null,
        repairOutDescription: this.repairForm.repairOutDescription
      };
      const res = await saveRePair(data);
      this.$refs.repairForm.resetFields();
      this.repairForm = {
        repairOutResult: ''
      };
      this.dialogVisible = false;
      if (this.repairForm.repairOutResult === 'REPAIR_SCRAP') {
        this.$router.push('/repair/pendingRepair');
      } else {
        this.onLoad(this.page);
        this.$message({
          type: 'success',
          message: res.data.msg
        });
      }

      // if (!this.repairForm.remark && this.repairForm.repairOutResult !== 1) {
      //   this.$message({
      //     type: 'warning',
      //     message: '请输入出维修意见说明'
      //   });
      //   return;
      // }
    },
    async handleRepair(row) {
      try {
        const res = await getDetail(row.id);
        const data = res.data.data;
        this.repairForm = {
          ...data.repairRegisterVO,
          ...data
        };
        await this.findWorkOrderNo(this.repairForm.workOrderId);
      } catch (e) {
        this.repairForm = {};
      }
      // this.repairForm.bomMroRefuelingList = this._map(this.repairForm.bomMroRefuelingList || [], (item) => {
      //   item.productSequenceNumber = item.productSn;
      //   item.sequenceNumber = item.newSn;
      //   return item;
      // });
      // this.repairForm.componentMroRefuelingList = this._map(this.repairForm.componentMroRefuelingList || [], (item) => {
      //   item.partNo = item.newPartNo;
      //   item.partName = item.newPartName;
      //   item.partModel = item.newPartModel;
      //   item.productSequenceNumber = item.newSn;
      //   return item;
      // });
      // this.findWorkOrderNo(this.repairForm.workOrderId);
      this.dialogVisible = true;
    },
    enterProductSequenceNumber(productSequenceNumber) {
      if (!productSequenceNumber) {
        this.$message({
          type: 'warning',
          message: '序列号不能为空！'
        });
        return;
      }
      this.onLoad(this.page, 'enter');
    },
    // 出维修操作
    // repairOutData() {
    //   let params = '';
    //   let ids = [];
    //   this.selectionList.forEach((ele) => {
    //     ids.push(ele.id);
    //   });
    //   if (this.outRepairType === 'out' && this.selectionList.length === 1) {
    //     if (!this.repairOutForm.qualifiedRouteId) {
    //       this.$message({
    //         type: 'warning',
    //         message: '请选择工序！'
    //       });
    //       return;
    //     }
    //     params = `result=0&qualifiedRouteId=${this.repairOutForm.qualifiedRouteId}`;
    //   } else if (this.outRepairType === 'out' && this.selectionList.length > 1) {
    //     params = 'result=0';
    //   } else {
    //     params = 'result=1';
    //   }
    //   repairOut(params, ids).then((res) => {
    //     if (res.data.code === 200) {
    //       this.$message({
    //         type: 'success',
    //         message: res.data.msg
    //       });
    //       if (this.outRepairType === 'out' && this.selectionList.length === 1) {
    //         this.$refs.repairOutForm.resetFields();
    //         this.repairOutForm.qualifiedRouteId = '';
    //         this.dialogVisible = false;
    //       }
    //       if (this.dataTempList.length > 0) {
    //         this.deleteTempData(this.ids);
    //       } else {
    //         this.onLoad(this.page);
    //       }
    //       this.getCalculateRate();
    //     }
    //   });
    // },
    // searchSubmit(form, done) {
    //   this.page.currentPage = 1;
    //   this.onLoad(this.page, 'search');
    //   done();
    // },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      if (params.repairTime && params.repairTime.length > 0) {
        params.repairStartTime = params.createTime[0];
        params.repairEndTime = params.createTime[1];
        delete this.search.createTime;
      }
      this.search = params;
      this.page.currentPage = 1;
      this.onLoad(this.page);
      done();
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page);
    },
    onLoad(page, params = {}) {
      this.loading = true;
      getPageList(page.currentPage, page.pageSize, Object.assign(params, this.search)).then((res) => {
        const resObj = res.data.data;
        let data = resObj.records || [];
        this.data = data;
        this.page.total = resObj.total;
        this.loading = false;
        this.selectionClear();
      });
    },
    // outRepair(type) {
    //   this.outRepairType = type;
    //   if (type === 'out') {
    //     if (this.selectionList.length > 1) {
    //       this.$message.warning('出维修只能操作一条数据!');
    //       return;
    //     }
    //     let productSequenceNumber = [];
    //     for (let i = 0; i < this.selectionList.length; i++) {
    //       if (this.selectionList[i].repairResult === '标记报废') {
    //         productSequenceNumber.push(this.selectionList[i].productSequenceNumber);
    //       }
    //     }
    //     if (productSequenceNumber.length) {
    //       this.$message.warning(`序列号${productSequenceNumber.join('，')}的维修状态为标记报废，不能出维修！`);
    //       return;
    //     }
    //     if (this.selectionList.length === 1) {
    //       this.repairOutForm = this.selectionList[0];
    //       this.dialogVisible = true;
    //       this.findWorkOrderNo(this.selectionList[0].workOrderId);
    //     } else {
    //       this.repairOutData();
    //     }
    //   } else {
    //     this.$confirm('是否确认将所有序列号返回重修?', {
    //       confirmButtonText: '确定',
    //       cancelButtonText: '取消',
    //       type: 'warning'
    //     }).then(() => {
    //       return this.repairOutData();
    //     });
    //   }
    // },
    // 获取工序
    findWorkOrderNo(workorderId) {
      getRouter(workorderId).then(
        (res) => {
          let data = this._get(res, 'data.data', []);
          this.stationList = this._map(data, (item) => {
            return {
              label: item.routeName,
              value: item.id
            };
          });
          console.log(this.stationList);
        },
        (error) => {}
      );
    },
    openPreview(index = 0, link) {
      this.$ImagePreview([{ url: link }], index, {
        closeOnClickModal: false
      });
    },
    handleDownload(link) {
      window.open(`${link}`);
    }
    // openScrapDialog() {
    //   if (this.selectionList.length > 1) {
    //     this.$message.warning('报废只能操作一条数据！');
    //     return;
    //   }
    //   if (this.selectionList[0].repairResult === '维修完成') {
    //     this.$message.warning('当前选择序列号的维修状态为维修完成，不能报废！');
    //     return;
    //   }
    //   this.scrapVisible = true;
    //   this.scrapForm = this.selectionList[0];
    // },
    // scrapSave() {
    //   if (!this.scrapForm.remark) {
    //     this.$message.warning('请输入报废说明！');
    //     return;
    //   }
    //   this.$confirm('确定将选择数据报废?', {
    //     confirmButtonText: '确定',
    //     cancelButtonText: '取消',
    //     type: 'warning'
    //   }).then(() => {
    //     let list = this._map(this.selectionList, (item) => {
    //       return {
    //         handleType: item.handleType,
    //         id: item.id,
    //         productId: item.productId,
    //         productSequenceNumber: item.productSequenceNumber,
    //         partMasterId: item.partMasterId,
    //         partNo: item.partNo,
    //         registrySource: item.registrySource,
    //         status: item.status,
    //         quantity: item.quantity,
    //         remark: this.scrapForm.remark
    //       };
    //     });
    //     scrap(list).then((res) => {
    //       this.scrapVisible = false;
    //       this.$message.success(res.data.msg);
    //       if (this.dataTempList.length > 0) {
    //         this.deleteTempData(this.ids);
    //       } else {
    //         this.onLoad(this.page);
    //       }
    //       this.getCalculateRate();
    //     });
    //   });
    // },
    // closeScrapDialog() {
    //   this.$refs.scrapForm.resetFields();
    //   this.scrapForm = {
    //     imageList: []
    //   };
    // },
    // getCalculateRate() {
    //   calculateRate().then((res) => {
    //     this.repairStraightThroughRate = this._get(res, 'data.data.repairStraightThroughRate', '');
    //     this.returnsWorkRate = this._get(res, 'data.data.returnsWorkRate', '');
    //     this.scrapeRate = this._get(res, 'data.data.scrapeRate', '');
    //   });
    // },
    // deleteTempData(ids) {
    //   ids.forEach((id) => {
    //     let i = this.dataTempList.findIndex((item) => item.id == id);
    //     this.dataTempList.splice(i, 1);
    //   });
    //   this.data = this._cloneDeep(this.dataTempList);
    //   if (this.data.length === 0) {
    //     this.onLoad(this.page);
    //   }
    // }
  }
};
</script>

<style scoped lang="scss">
.img-list {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}
::v-deep .el-table {
  margin-bottom: 10px;
}
.tdStyle {
  background: #fafafa;
  font-weight: 700;
  color: #909399;
  text-align: right;
  width: auto;
  padding-right: 20px;
  white-space: nowrap;
}
.tdStyle2 {
  white-space: nowrap;
  background: #fafafa;
  font-weight: 700;
  padding: 0 10px;
}
.tdStyle3 {
  text-align: center;
}
td {
  padding: 5px;
  border: 1px solid #ebeef5;
}

::v-deep .el-table .repair-select-row {
  background-color: #caf982 !important;
}
.detail-title {
  font-weight: bold;
  font-size: 14px;
  margin: 10px 0;
}
.detail-title.noData {
  text-align: center;
}
.statistics {
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  justify-content: space-around;
  font-size: 18px;
  align-items: center;
  .content {
    padding: 10px;
    font-size: 20px;
    .repairStraightThroughRate {
      color: yellowgreen;
    }
    .returnsWorkRate {
      color: orange;
    }
    .scrapeRate {
      color: red;
    }
  }
}
.repairWay {
  display: flex;
  flex-direction: column;
}

.station {
  display: flex;
  flex-direction: row;
}

::v-deep .el-dialog__wrapper .el-dialog {
  .avue-crud__menu {
    display: none;
  }
}

::v-deep .avue-crud__menu {
  display: none;
}
</style>
